/**
 * 
 */
package com.rostami.tutorial.spring.scope;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author Alireza
 *
 */
public class HelloScope {

	private String message;
	public String getMessage() {
		return message;
	}



	public void setMessage(String message) {
		this.message = message;
	}



	/**
	 * 
	 */
	public HelloScope() {
	}
	
	
	
	public static void main(String [] args){
		try{
			@SuppressWarnings("resource")
			ApplicationContext context = new ClassPathXmlApplicationContext("SpringConfig.xml");
			
			HelloScope scope = (HelloScope) context.getBean("scopeBean");
			scope.setMessage("Hi");
			System.out.println(scope.getMessage());
			
			HelloScope scope2 = (HelloScope) context.getBean("scopeBean");
			System.out.println(scope2.getMessage());
			
			HelloScope scopeSingle = (HelloScope) context.getBean("scopeSingleBean");
			scopeSingle.setMessage("Hi single");
			System.out.println(scopeSingle.getMessage());
			
			HelloScope scopeSingle2 = (HelloScope) context.getBean("scopeSingleBean");
			System.out.println(scopeSingle2.getMessage());
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}
